
<div id="canvass-sheet-list-print">
	<table border="1" width="100%">
        <col width="10%"/>
        <col width="5%"/>
        <col width="5%"/>
        <col width="60%"/>
        <col width="20%"/>
		<tbody>

		<?php
		
		// for checking new-ness
		$one_year_ago = strtotime ("-1 year");
		
		$prev_address1 = ""; 
		foreach ($entries as $row) 
		{ 
		?>


				<?php 
				if (strcmp ($row->address1, $prev_address1) != 0)
				{
                    echo "<tr><td colspan=\"5\"><center><p class=\"canvass-address\">";
				    echo $row->address1 . ", " . $row->address2;
                    echo "</p></center></td></tr>";
				    $prev_address1 = $row->address1;
				}
				?>
				
				<tr>
        	    <td colspan="4"> 
        	        <?php echo "<strong>" . $row->surname . ", " . $row->first_names . "</strong> " ?>
                    <?php if (!is_null ($row->first_seen_date))
                      {
                          $new_date = strtotime ($row->first_seen_date);
                          
                          if ($new_date >= $one_year_ago)
                          {
                            echo " **NEW: " . strftime ("%d %b %Y", $new_date) . "**";
                          }
                      }
                    ?>
        	        <?php if (!is_null ($row->bday_18))
                      {
                          echo " (18th: " . strftime ("%d %b %Y", strtotime ($row->bday_18)) . ")";
                      }
                    ?>
        	    </td>
                <td>
                <?php if (!is_null ($row->last_voted))
                {
                    echo "Last voted: " . strftime ("%b %Y", strtotime ($row->last_voted));
                    
                    $pos = strpos($row->vote_type, "Postal");
                    
                    if (!($pos === false)) 
                    {
                        echo " **POSTAL**";
                    }                    
                    
                    echo " (" . $row->election_type . ")";
                }
                ?>
                </td>        	    
        	    </tr>
        	    
                <?php if (!is_null ($row->last_contacted))
                {
                ?>
        	    <tr>
                <td><?php echo strftime ("%d %b %Y", strtotime ($row->last_contacted)) ?></td>
                <td><?php 
                    if (is_null ($row->rank))
                    {
                        echo "-";
                    }
                    else
                    {
                        echo $row->rank;
                    }
                    ?></td>
                <td><?php 
                    if (is_null ($row->party))
                    {
                        echo "-";
                    }
                    else
                    {
                        echo $row->party; 
                    }
                    ?></td>
                <td colspan="2"><?php echo $row->notes ?></td>
				</tr>
				<?php
				}
				?>
				
				<tr>
				<td colspan="5">
				<p class="canvass-note-entry">Notes</p>
				</td>
				</tr>
				
		<?php } ?>
	</tbody>
</table>

</div>
